public with sharing class OpportunitySharingClass {
   
    public static void deleteOpportunitySharingByRowCause(Map<ID,ID> objectIdToNewUserIdMap, String rowCauseToFind){
        List<OpportunityShare> deleteShares = new List<OpportunityShare>();

        for (OpportunityShare posShare : [SELECT UserOrGroupId, RowCause, OpportunityId, Id, OpportunityAccessLevel 
                                           FROM OpportunityShare 
                                           WHERE OpportunityId IN :objectIdToNewUserIdMap.keySet()
                                             AND RowCause = :rowCauseToFind]){
            if (ObjectIdToNewUserIdMap.get(posShare.OpportunityId) != posShare.UserOrGroupId){
                deleteShares.add(posShare);
            }
        }
        if (!deleteShares.isEmpty()) {
            delete deleteShares;
        }          
    }
}